#pragma once
#ifndef PRIMIRIVE_H
#define PRIMIRIVE_H

#include <QtOpenGL>
#include <QVector>
#include <QVarLengthArray>
#include "MyVertex.h"

namespace CAD_CAM
{

	class Primitive
	{
	public:
		Primitive(int verticesCount, int indicesCount);
		Primitive(QVector3D position, int verticesCount, int indicesCount);
		Primitive(QVector3D position, float size, int verticesCount, int indicesCount);
		Primitive(float size, int verticesCount, int indicesCount);

		virtual  ~Primitive(void);

		virtual void DrawShader(QGLShaderProgram& shaderProgram, QMatrix4x4& viewMatrix, QMatrix4x4& projectionMatrix) = 0;
		void initBuffers(QGLBuffer::UsagePattern usage = QGLBuffer::StaticDraw);
		QVector3D translation;

	public slots:
		void setWidth(double width);
		void setHeight(double height);
		void setLength(double length);
		void setColor(QColor c);
		void setColor(QVector3D c);
		void translate(QVector3D vector);

	protected:
		void init(QVector3D position, QVector3D size, int verticesCount, int indicesCount);

		QGLBuffer mVertexVBO;
		QGLBuffer mIndexVBO;
		MyVertex* verticesArray;
		QVector<GLuint> indicesArray;
		QVector3D color;

		int vertices, indices;
		bool isInited;
		// ----- methods
		void buildTorus(MyVertex* verticesArray, GLuint* indicesArray);
	
		QVector3D sizeScale;
	};
}
#endif // PRIMIRIVE_H